﻿using System;
using System.Threading;

namespace HslCommunication.Core
{
	/// <summary>
	/// 一个双检锁的示例，适合一些占内存的静态数据对象，获取的时候才实例化真正的对象
	/// </summary>
	// Token: 0x02000120 RID: 288
	internal sealed class Singleton
	{
		// Token: 0x060018B6 RID: 6326 RVA: 0x0007DB50 File Offset: 0x0007BD50
		public static Singleton GetSingleton()
		{
			bool flag = Singleton.SValue != null;
			Singleton svalue;
			if (flag)
			{
				svalue = Singleton.SValue;
			}
			else
			{
				Monitor.Enter(Singleton.m_lock);
				bool flag2 = Singleton.SValue == null;
				if (flag2)
				{
					Singleton value = new Singleton();
					Volatile.Write<Singleton>(ref Singleton.SValue, value);
					Singleton.SValue = new Singleton();
				}
				Monitor.Exit(Singleton.m_lock);
				svalue = Singleton.SValue;
			}
			return svalue;
		}

		// Token: 0x0400058F RID: 1423
		private static object m_lock = new object();

		// Token: 0x04000590 RID: 1424
		private static Singleton SValue = null;
	}
}
